-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-37558][DOC] Improve spark sql cli document #34821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Test build #145954 has finished for PR 34821 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
Test build #145970 has finished for PR 34821 at commit
|
|
ping @cloud-fan |
|
Kubernetes integration test starting |
|
Test build #145972 has finished for PR 34821 at commit
|
| ## Spark SQL CLI Interactive Shell Commands | ||
|
|
||
| When `./bin/spark-sql` is run without either the `-e` or `-f` option, it enters interactive shell mode. | ||
| Use `;` (semicolon) to terminate commands, but user can escape `;` by `\\;`. Comments in scripts can be specified using the `--` prefix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if ; is not the end of the line? does it still terminate commands?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should explain more about ;
- what if it's inside a comment?
SELECT /* xxx; */ 1; - is
;the only way to terminate commands? what if I typeSELECT 1and then press enter? - can we put multiple commands in a single line?
SELECT 1; SELECT 2;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about current?
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
Kubernetes integration test status failure |
|
Test build #145977 has finished for PR 34821 at commit
|
| Use `;` (semicolon) to terminate commands. Notice: | ||
| 1. CLI use `;` to terminate commands only when it's at the end of line and it's not escaped by `\\;`. | ||
| 2. `;` is the only way to terminate commands, if user type `SELECT 1` and press enter, console will just wait for input. | ||
| 3. If user type multiple commands in one line like `SELECT 1; SELECT 2;`, commands `SELECT 1` and `SELECT 2` will be executed separatly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and CLI only shows the result of the last command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and CLI only shows the result of the last command?
No, both result.
spark-sql> select 1; select 2;
1
Time taken: 3.819 seconds, Fetched 1 row(s)
2
Time taken: 0.077 seconds, Fetched 1 row(s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user types multiple commands in one line like SELECT 1; SELECT 2;, then commands SELECT 1 and SELECT 2 will be executed separately.
| /* This is a comment contains ; | ||
| */ SELECT 1; | ||
| ``` | ||
| it will terminate commands into `/* This is a comment contains ` and `*/ SELECT 1`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and we hit failures when executing /* This is a comment contains
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spark-sql> /* This is a comment contains ;
Error in query:
Unclosed bracketed comment(line 1, pos 0)
== SQL ==
/* This is a comment contains ;
^^^
spark-sql> */ SELECT 1;
Error in query:
extraneous input '*/' expecting {'(', 'ADD', 'ALTER', 'ANALYZE', 'CACHE', 'CLEAR', 'COMMENT', 'COMMIT', 'CREATE', 'DELETE', 'DESC', 'DESCRIBE', 'DFS', 'DROP', 'EXPLAIN', 'EXPORT', 'FROM', 'GRANT', 'IMPORT', 'INSERT', 'LIST', 'LOAD', 'LOCK', 'MAP', 'MERGE', 'MSCK', 'REDUCE', 'REFRESH', 'REPLACE', 'RESET', 'REVOKE', 'ROLLBACK', 'SELECT', 'SET', 'SHOW', 'START', 'TABLE', 'TRUNCATE', 'UNCACHE', 'UNLOCK', 'UPDATE', 'USE', 'VALUES', 'WITH'}(line 1, pos 5)
== SQL ==
*/ SELECT 1
-----^^^
spark-sql>
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
Any more suggestion? |
| -- This is a comment; | ||
| SELECT 1; | ||
| ``` | ||
| This comment line will just be ignored. If `;` in a bracketed command and not at the end of line, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then this comment line will be ignored. If ; appears in a bracketed command
(and similarly for the other lines below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| </tr> | ||
| <tr> | ||
| <td><code>dfs <dfs command></code></td> | ||
| <td>Executes a <a href="https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HDFSCommands.html#dfs">dfs command</a> from the Hive shell.</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only for executing commands vs HDFS or would it work on other distributed storage?
We should say HDFS if it's HDFS.
Also, not "Hive shell" here right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, how about current?
|
Test build #146000 has finished for PR 34821 at commit
|
|
Kubernetes integration test starting |
Done |
|
Test build #146158 has finished for PR 34821 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
| ## Path interpretation | ||
|
|
||
| Spark SQL CLI supports running SQL from initialization script file(`-i`) or normal SQL file(`-f`), If path url don't have a schema component, the path will be handled as local file. | ||
| For example: `/path/to/spark-sql-cli.sql` equals to `file:///path/to/spark-sql-cli.sql`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's also mention that people can use Hadoop supported filesystem such as s3://...
cloud-fan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for a few minor comments
|
Test build #146189 has finished for PR 34821 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
Co-authored-by: Wenchen Fan <[email protected]>
|
Test build #146220 has finished for PR 34821 at commit
|
|
Kubernetes integration test starting |
|
Test build #146223 has finished for PR 34821 at commit
|
Scrrenshot updated in pr desc |
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
Kubernetes integration test status failure |
|
Test build #146227 has finished for PR 34821 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
thanks, merging to master! |
What changes were proposed in this pull request?
Current Spark SQL CLI doc just show simple usage. In this pr we add a detail doc for spark sql cli.
Why are the changes needed?
Make doc about Spark SQL CLI more clear. help user to use this command line tool.
Does this PR introduce any user-facing change?
No
How was this patch tested?